package ray.mgocc.title;

import ray.mgocc.Time;

public class NightOwl extends WeekTitle{
    public String getName(){ return "NIGHT OWL";}
    public int getPriority(){ return 16;}
    public int getPlayTimeThreshold(){ return 3;}
    public void init(){
        super.init();
        add(new EnvgRequirement());
    }
    class EnvgRequirement extends Requirement{
        public String getName(){return "ENVG";}
        private Time getEnvgTime(){
            return getTime("Personal Scores.Total Time Using ENVG");
        }
        private Time getThreshold(){
            Time all = getTime("Total.PLAY TIME");
            Time threshold = new Time((long)(all.toSecond()*0.05));
            return threshold;
        }
        public double getRatio(){
            double ratio;
            long threshold = getThreshold().toSecond();
            if(0==threshold){
                ratio = 0;
            }else{
                ratio = ((double)getEnvgTime().toSecond())/threshold;
            }
            return ratio;
        }
        public String toString(){
            return super.toString()+"("+getThreshold()+"<="+getEnvgTime()+")";
        }
    }
}

